Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new Channel API for experimental plugins feature #5141

Merged
merged 23 commits into from
Feb 3, 2024

Conversation

Mm2PL
Copy link
Collaborator

@Mm2PL Mm2PL commented Feb 1, 2024

Example usage:

local pajs = c2.Channel.by_name("pajlada", c2.Platform.Twitch)
pajs:add_system_message("Hello there")

When Chatterino deletes the Channel, all lua ChannelRefs to it expire and using them will produce an error. It is possible to check for this before using those functions with Channel:is_valid(). I expect that other weak objects will have identical methods, I created IWeakResource interface class which defines this method.

Breaking

This PR removes c2.system_msg and c2.send_msg.

@Mm2PL Mm2PL requested a review from pajlada February 1, 2024 17:51
@Mm2PL Mm2PL changed the title Fix lua::push<T>(L, T) for enums Create Lua Channel API Feb 1, 2024
@Mm2PL Mm2PL changed the title Create Lua Channel API Add a new Channel API for experimental plugins feature Feb 1, 2024
Comment on lines 36 to 45
class Channel implements IWeakResource {
is_valid(): boolean;
get_name(): string;
get_type(): ChannelType;
get_display_name(): string;
is_twitch_channel(): boolean;

static by_name(name: string, platform: Platform): null | Channel;
static by_twitch_id(id: string): null | Channel;
}
Copy link
Contributor

@Wissididom Wissididom Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there send_message and add_system_message missing, because send_msg and system_msg were removed a few lines below this class definition and in the plugin-meta.lua there are those functions defined as member of Channel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are missing, thank you for reminding me of that

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just add the missing documentation to class Channel

@pajlada pajlada merged commit 8e9aa87 into master Feb 3, 2024
20 checks passed
@pajlada pajlada deleted the feature/lua-channel-api branch February 3, 2024 18:12
devJimmyboy pushed a commit to devJimmyboy/chatterino7 that referenced this pull request Feb 11, 2024
@4rneee
Copy link
Contributor

4rneee commented Feb 17, 2024

I saw this PR just now and noticed two things:

  1. With the removal of c2.system_msg and c2.send_msg we now need the channel name and platform to send a (system-)message. The CommandContext should therefore be extended to also contain the platform so that replying to a command is possible without assuming that the command was triggered in a twitch channel.
  2. Since this changes quit a lot how the API works it would be great if docs/wip-plugins.md would be changed to stay consistent with the current implementation.

@pajlada
Copy link
Member

pajlada commented Feb 17, 2024

@4rneee Could you create an issue to track that? Super helpful feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants